#!/usr/bin/python
import sys

# repeat table.
sbase = {}
cbase = {}
total = 0
i = 0
fin = open(sys.argv[1],"rb")
for line in fin:
	# skips.
	if i < 3: 
		i += 1
		continue
	
	# tokenize.
	tmp = line.split()
	cat = tmp[10]
	a = int(tmp[5])
	b = int(tmp[6])
	size = abs(a-b)
	
	# Check for category.
	if cat.count("/") == 0:
		# simple.
		if cat not in sbase:
			sbase[cat] = [0,0]
		sbase[cat][0] += size
		sbase[cat][1] += 1
	else:
		# complex.
		tmp1 = cat.split("/")
		acat = tmp1[0]
		bcat = tmp1[1]
		
		if acat not in cbase:
			cbase[acat] = {}
		if bcat not in cbase[acat]:
			cbase[acat][bcat] = [0,0]
		cbase[acat][bcat][0] += size	
		cbase[acat][bcat][1] += 1
		
	# mark total.
	total += size
fin.close()

# print out summary.
print "simple"
for cat in sbase:
	print "%s\t%i\t%i" % (cat, sbase[cat][1], sbase[cat][0])
	

print "complex"
for cat in cbase:
	print cat
	for scat in cbase[cat]:
		print "%s\t%i\t%i" % (scat, cbase[cat][scat][1],cbase[cat][scat][0])
